<meta charset="utf-8">
<?php  
require_once("mysql.php"); 
/*mysql_connect("localhost","root","1");
mysql_select_db("my_db");  */ 
$username=$_POST['username'];  
$password=$_POST['password']; 
$pwd_again=$_POST['pwd_again']; 
$name=$_POST['name1']; 
$sex=$_POST['sex']; 
$xueyuan=$_POST['school']; 
$school=$_POST['name']; 
$zhuanye=$_POST['zhuanye'];  
$phone=$_POST['phone'];  
$email=$_POST['email'];
$pdh="select * from work where username='$username'";
$resul = mysql_query($pdh);
$count=mysql_num_rows($resul);
if($count>0)
{
	echo"<script type='text/javascript'>alert('用户名已存在,请重新输入');location='zhuce.php';</script>";
	break;
}
else
{
	 $sql="insert into work(username,password,name,sex,school,xueyuan,zhuanye,phone,email) values('$username','$password','$name','$sex','$school','$xueyuan','$zhuanye','$phone','$email')";   
     $result=mysql_query($sql); 
     if(!$result) 
     {  
        echo"<script type='text/javascript'>alert('注册失败');location='zhuce.php';</script>";  
     } 
     else   
     {  
        echo"<script type='text/javascript'>alert('注册成功');location='login.php';</script>";  
     }  
}
  
?> 
